Skip to content

Conversation

z-sztrom
Copy link
Contributor

Applicable Issues

Description of the Change

Functionality validating PURLs added.

Alternate Designs

Possible Drawbacks

Sign-off

Developer's Certificate of Origin 1.1

By making a contribution to this project, I certify that:

(a) The contribution was created in whole or in part by me and I
have the right to submit it under the open source license
indicated in the file; or

(b) The contribution is based upon previous work that, to the best
of my knowledge, is covered under an appropriate open source
license and I have the right under that license to submit that
work with modifications, whether created in whole or in part
by me, under the same open source license (unless I am
permitted to submit under a different license), as indicated
in the file; or

(c) The contribution was provided directly to me by some other
person who certified (a), (b) or (c) and I have not modified
it.

(d) I understand and agree that this project and the contribution
are public and that a record of the contribution (including all
personal information I submit with it, including my sign-off) is
maintained indefinitely and may be redistributed consistent with
this project or the open source license(s) involved.

Signed-off-by: Roman Szturc [email protected]

@z-sztrom z-sztrom changed the title Validate purls Validate PURLs Sep 25, 2025
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this class required , we can directly fetch the details from the hashmap ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The last method of the class ensures that property is a Boolean. If fetching from a HashMap directly, the code would have to follow the fetch making it harder to read. That's why a new class was introduced.


public static <T> T getProperty(HashMap<String, Object> validationProperties, String property, T defValue) {
Object object = validationProperties.get(property);
if (object == null)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

code can be optimised as follows:
object instanceof Boolean ? (Boolean) object : defValue;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but then I lose the error message. And it's important here as it would be difficult to investigate why default value was returned instead of value from HashMap. I tried to find how to check it dynamically (something linek 'object instance of T'), but generics are compile-time-only feature...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants